package reflect;

/**
 * 调用有参方法
 */
import java.lang.reflect.Method;

public class ReflectDemo5 {
    public static void main(String[] args) throws Exception{
        Class cls=Class.forName("reflect.Person");
        Object obj =cls.newInstance();

        //say(String info)
        Method method=cls.getMethod("say",String.class);
        method.invoke(obj,"你好");//第二个参数开始为实参

        Method method1=cls.getMethod("say", String.class, int.class);
        method1.invoke(obj,"嘿嘿",3);
    }
}
